
const ROLE_ROOT = 'root';
const ROLE_ADMIN = 'admin';
const ROLE_MEMBER = 'member';
export default function (initialState) {
    //获取当前用户对应的角色的数组
    const roles = initialState?.currentUser?.roles;
    return {
        //如果当前用户的角色包括root角色的话就返回true,就表示有权限
        canReadRole:roles?.includes(ROLE_ROOT),//可以访问角色的路由
        canReadUser:roles?.includes(ROLE_ROOT)||roles?.includes(ROLE_ADMIN),
        canReadMenu:roles?.includes(ROLE_ROOT)||roles?.includes(ROLE_ADMIN),
        canReadUserPassword:roles?.includes(ROLE_ROOT),//是否允许观看密码字段
        canDeleteUser:roles?.includes(ROLE_ROOT)//是否允许删除用户
    }
}